package com.sysu.minsysu.zxcx;

import com.sysu.minsysu.R;

import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ArticleTitleItem extends RelativeLayout{

	private ImageView mImageView;
	private TextView mTextView;
	
	private static final int mImageViewID = 3284;
	private static final int mTextViewID = 2838;
	
	private boolean beenRead=false;
	
	public ArticleTitleItem(Context context, String text) {
		super(context);
		setLayoutParams( new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		
		LayoutParams imageLayoutParams = new LayoutParams( 48,48);
		imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		imageLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
		mImageView = new ImageView(context);
		mImageView.setLayoutParams( imageLayoutParams );
		mImageView.setImageResource(R.drawable.article_new);
		mImageView.setId(mImageViewID);
		
		TextView textView = new TextView(context);
		LayoutParams textViewLayoutParams = new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		textViewLayoutParams.addRule(RelativeLayout.RIGHT_OF, mImageViewID);
		textViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
		textView.setLayoutParams( textViewLayoutParams );
		textView.setTextColor(Color.BLACK);
		textView.setTextSize(18);
		textView.setText(text);
		textView.setGravity(Gravity.CENTER_VERTICAL);
		mTextView = textView;
		
		addView(mImageView);
		addView(mTextView);
	}
	public void setBeenRead(){
		mImageView.setImageResource(R.drawable.article_read);
		beenRead = true;
	}
	
	public boolean isBeenRead(){
		return beenRead;
	}
	
}
